<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            height: 200px;
            width: 200px;
            background-color: green;
        }
    </style>
</head>

<body>
    <div id="box">

    </div>
    <script>
        function throttle(fn, delay) {
            let flag = true;
            console.log(flag,"1");
            return () => {
                console.log(flag,"flag");
                if (!flag) return;
                flag = false;
                timer = setTimeout(() => {
                    fn();
                    flag = true;
                }, delay);
            };
        }

        const oBox = document.getElementById("box");
        oBox.addEventListener(
            "click",
            throttle(() => {
                console.log(111);
            }, 1000)
        );


    </script>
</body>

</html>